/**
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file -- DO NOT EDIT!

#ifndef ES2PANDA_PUBLIC_ES2PANDA_LIB
#define ES2PANDA_PUBLIC_ES2PANDA_LIB

// Switch off the linter for C header
// NOLINTBEGIN
//

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <uchar.h>

#ifdef __cplusplus
extern "C" {
#endif

#define ES2PANDA_LIB_VERSION 1

typedef struct es2panda_Config es2panda_Config;
typedef struct es2panda_Context es2panda_Context;

typedef struct es2panda_variantDoubleCharArrayBool {
    int index;
    union {
        double d;
        char *c;
        bool b;
    } variant;
} es2panda_variantDoubleCharArrayBool;

enum es2panda_variantIndex {
    DOUBLE = 0,
    CHAR = 1,
    BOOL = 2,
};

typedef struct es2panda_Program es2panda_Program;
typedef struct es2panda_ExternalSource es2panda_ExternalSource;
typedef struct es2panda_AstNode es2panda_AstNode;
typedef struct es2panda_FunctionSignature es2panda_FunctionSignature;
typedef struct es2panda_Language es2panda_Language;
typedef struct es2panda_SourcePosition es2panda_SourcePosition;
typedef struct es2panda_SourceRange es2panda_SourceRange;
typedef struct es2panda_SrcDumper es2panda_SrcDumper;
typedef struct es2panda_AstDumper es2panda_AstDumper;
typedef struct es2panda_LabelPair es2panda_LabelPair;
typedef struct es2panda_ScriptFunctionData es2panda_ScriptFunctionData;
typedef struct es2panda_ImportSource es2panda_ImportSource;
typedef struct es2panda_Signature es2panda_Signature;
typedef struct es2panda_ValidationInfo es2panda_ValidationInfo;
typedef struct es2panda_Type es2panda_Type;
typedef struct es2panda_Variable es2panda_Variable;
typedef struct es2panda_Scope es2panda_Scope;
typedef struct es2panda_AstVisitor es2panda_AstVisitor;
typedef struct es2panda_CodeGen es2panda_CodeGen;
typedef struct es2panda_VReg es2panda_VReg;
typedef void (*NodeTraverser)(es2panda_AstNode *);
typedef es2panda_AstNode *(*NodeTransformer)(es2panda_AstNode *);
typedef bool (*NodePredicate)(es2panda_AstNode *);

enum es2panda_ContextState {
    ES2PANDA_STATE_NEW,
    ES2PANDA_STATE_PARSED,
    ES2PANDA_STATE_SCOPE_INITED,
    ES2PANDA_STATE_CHECKED,
    ES2PANDA_STATE_LOWERED,
    ES2PANDA_STATE_ASM_GENERATED,
    ES2PANDA_STATE_BIN_GENERATED,

    ES2PANDA_STATE_ERROR
};
typedef enum es2panda_ContextState es2panda_ContextState;

#include "generated/es2panda_lib/es2panda_lib_enums.inc"

struct es2panda_Impl {
    int version;

    es2panda_Config *(*CreateConfig)(int argc, char const **argv);
    void (*DestroyConfig)(es2panda_Config *config);

    es2panda_Context *(*CreateContextFromFile)(es2panda_Config *config, char const *source_file_name);
    es2panda_Context *(*CreateContextFromString)(es2panda_Config *config, char const *source, char const *file_name);
    es2panda_Context *(*ProceedToState)(es2panda_Context *context, es2panda_ContextState state);  // context is consumed
    void (*DestroyContext)(es2panda_Context *context);

    es2panda_ContextState (*ContextState)(es2panda_Context *context);
    char const *(*ContextErrorMessage)(es2panda_Context *context);

    es2panda_Program *(*ContextProgram)(es2panda_Context *context);
    es2panda_AstNode *(*ProgramAst)(es2panda_Program *program);
    es2panda_ExternalSource **(*ProgramExternalSources)(es2panda_Program *program, size_t *len_p);
    char const *(*ExternalSourceName)(es2panda_ExternalSource *e_source);
    es2panda_Program **(*ExternalSourcePrograms)(es2panda_ExternalSource *e_source, size_t *len_p);
    void (*AstNodeForEach)(es2panda_AstNode *ast, void (*func)(es2panda_AstNode *, void *), void *arg);

#define SET_NUMBER_LITERAL_DECL(name, type) bool (*SetNumberLiteral##name)(es2panda_AstNode * node, type new_value)

    SET_NUMBER_LITERAL_DECL(Int, int32_t);
    SET_NUMBER_LITERAL_DECL(Long, int64_t);
    SET_NUMBER_LITERAL_DECL(Double, double);
    SET_NUMBER_LITERAL_DECL(Float, float);

#undef SET_NUMBER_LITERAL_DECL

#include "generated/es2panda_lib/es2panda_lib_decl.inc"
};

struct es2panda_Impl const *es2panda_GetImpl(int version);

// NOLINTEND

#ifdef __cplusplus
}
#endif

#endif
